package com.szh.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

import static com.szh.common.constant.MQConstant.*;

@Configuration
public class DelayQueueRabbitConfig {
    
    @Bean
    Queue queue() {
        return new Queue(DELAY_QUEUE_NAME, true, false, false);
    }

    @Bean
    CustomExchange customExchange() {
        Map<String, Object> args = new HashMap<>(8);
        args.put("x-delayed-type", "direct");
        return new CustomExchange(DELAY_EXCHANGE_NAME, DELAY_EXCHANGE_TYPE, true, false,args);
    }

    @Bean
    Binding binding() {
        return new Binding(DELAY_QUEUE_NAME, Binding.DestinationType.QUEUE, DELAY_EXCHANGE_NAME,DELAY_ROUTE_KEY,null);
    }
}
